<template>
	<view id="container">
		<!-- <view @click="back" class="back">
			<image src="../../static/map/back-icon.png" mode=""></image>

		</view> -->
		<map class="map" :latitude="latitude" :longitude="longitude" :markers="markers">
		</map>
	</view>
</template>

<script src="https://map.qq.com/api/gljs?v=1.exp&key=H5OBZ-6SXKK-ETJJH-AC5ZY-ZTMPE-5DFZF"></script>
<script>
	export default {
		data() {
			return {
				longitude: 113.704498,
				latitude: 34.774349,
				markers: [{
					longitude: 113.704498,
					latitude: 34.774349,

				}]

			}
		},
		onLoad(options) {
			let that = this;
			uni.getLocation({
				type: 'gcj02', //返回可以用于uni.openLocation的经纬度
				success: function(res) {
					console.log(res);
					// const latitude = res.latitude;
					// const longitude = res.longitude;
					let markers = [{
						id: 0,
						latitude: res.latitude,
						longitude: res.longitude,
						iconPath: '../../static/map/staring.png',
						width: 40,
						height: 40

					}, {
						id: 1,
						latitude: that.latitude,
						longitude: that.longitude,
						iconPath: '../../static/map/end.png',
						width: 40,
						height: 40
					}]
					uni.openLocation({
						latitude: that.latitude,
						longitude: that.longitude,
						name: "目的地",
						success: function(res) {
							console.log(res);
						}
					});
				},
				fail: function(err) {
					console.log(err)
				}
			});

		},
		methods: {
		back(){
			uni.navigateBack({
				delta:2
			})
		}

		}
	}
</script>

<style scoped>
	#container {
		width: 750rpx;
		height: 1624rpx;
		/* background-color: #007AFF; */
	}

	.map {
		width: 750rpx;
		height: 1624rpx;
	}

	.back {
		display: flex;
		justify-content: center;
		align-items: center;
		width: 60rpx;
		height: 60rpx;
		position: absolute;
		left: 40rpx;
		top: 70rpx;
		z-index: 9;
	}

	.back image {
		width: 30rpx;
		height: 60rpx;
		/* position: absolute; */
	}
</style>
